package cn.lazyturtle.bugpush.controller;

import cn.lazyturtle.bugpush.service.BugPushCallBackService;
import cn.lazyturtle.bugpush.service.PushBugService;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Objects;


/**
 * <p>
 * BugController :
 * </p>
 *
 * @author cwh
 * @since 2021-09-01
 */
@RestController
@RequestMapping("/get-call-back")
public class CallBackController {
    private final BugPushCallBackService bugPushCallBackService;

    @Autowired
    public CallBackController(BugPushCallBackService bugPushCallBackService) {
        this.bugPushCallBackService = bugPushCallBackService;
    }

    @PostMapping("/ding-ding")
    public Object dealDingDingCallBack(@RequestParam(value = "msg_signature", required = false) String signature,
                                       @RequestParam(value = "timestamp", required = false) Long timeStamp,
                                       @RequestParam(value = "nonce", required = false) String nonce,
                                       @RequestBody(required = false) JSONObject encrypt){
        return bugPushCallBackService.callback(signature, timeStamp, nonce, encrypt);
    }

}
